home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-02-28 | 4.1 KB | 123 lines | [TEXT/MPS ] |
-
- // ---- End Project Data ----
-
-
- // ---- File Size Doesn't Matter.t ----
-
- // Before Script for "ResizeSampleApp"
- // Copyright 1993-1994 Apple Computer, Inc. All rights reserved.
-
- ResizeSampleApp :=
- {title: "Resize Sample",
- viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
- viewSetupFormScript:
- func()
- begin
- local a := GetAppParams();
- self.viewBounds := RelBounds(a.appAreaLeft, a.appAreaTop, a.appAreaWidth, a.appAreaHeight);
- end,
- _proto: protoApp,
- debug: "ResizeSampleApp"
- };
-
- sizeableView := /* child of ResizeSampleApp */
- {viewFlags: 513,
- viewFormat: 337,
- viewBounds: {left: 67, top: 83, right: 169, bottom: 161},
- viewClickScript:
- func(unit)
- begin
- local r, newR, newB, newBounds; // used inside loop
-
- // deltas keep track of how close the tap point is to the corner.
- local deltaX := :GlobalBox().right - GetPoint(firstX, unit);
- local deltaY := :GlobalBox().bottom - GetPoint(firstY, unit);
-
- // if we're near the lower right hand corner, resize the view.
- // note we use ABS. Because of "sloppy clicking" it's possible
- // for this view's viewClickScript to get called even when
- // the tap is technically outside the bounds, and it seems like
- // a good idea to let these taps resize the view too.
-
- if ABS(deltaX) < 10 and ABS(deltaY) < 10 then
- begin
- InkOff(unit);
-
- // make a rectangle for the drag animation
- r := MakeShape(viewBounds);
- :Parent():DrawShape(r, XORRectStyle); // draw frame
- newBounds := Clone(viewBounds);
-
- // loop until stroke is finished
- while not StrokeDone(unit) do
- begin
- // track the pen, and if it's moved, update the wire frame
- newR := GetPoint(finalX, unit) + deltaX;
- newB := GetPoint(finalY, unit) + deltaY;
- if newR <> newBounds.right or newB <> newBounds.bottom then
- begin
- newBounds.right := newR;
- newBounds.bottom := newB;
- :Parent():DrawShape(r, XORRectStyle); // undraw old frame
- ScaleShape(r, nil, newBounds);
- :Parent():DrawShape(r, XORRectStyle); // draw frame
- Sleep(1); // short delay, maybe save batteries?
- end;
- end;
- :Parent():DrawShape(r, XORRectStyle); // undraw old frame
-
- newBounds.right := GetPoint(finalX, unit) + deltaX;
- newBounds.bottom := GetPoint(finalY, unit) + deltaY;
- // just setting viewBounds won't work, use SyncView or SetValue.
- SetValue(self, 'viewBounds, newBounds); // call viewChangedScript
- end
- else
- begin
- // just for fun, drag the view if the tap is anywhere else
- :Drag(unit, nil);
- // clean up viewBounds after Drag munges them.
- // this is only valid for parent top/left justified views!
- local b := :GlobalBox();
- local p := :Parent():GlobalBox();
- b.top := b.top - p.top;
- b.left := b.left - p.left;
- b.bottom := b.bottom - p.top;
- b.right := b.right - p.left;
- SetValue(self, 'viewBounds, b); // call viewChangedScript
- end;
- TRUE; // we've handled the tap
- end,
- viewSetupFormScript:
- func()
- begin
- // need writeable copy of viewBounds for viewClickScript
- If IsReadOnly(viewBounds) then
- self.viewBounds := Clone(viewBounds);
- end,
- XORRectStyle:
- // used in viewClickScript for animating frame during resize.
-
- {transferMode: modeXor, penSize: 1, penPattern: vfGray},
- viewclass: 74,
- debug: "sizeableView"
- };
-
-
-
- _view000 := /* child of ResizeSampleApp */
- {text: "Drag lower right corner to change size.",
- viewBounds: {top: -40, left: 0, right: 0, bottom: -20},
- viewJustify: 8388790
- ,
- _proto: protoStaticText
- };
-
-
-
-
-
-
-
- // ---- Beginning of section for non used Layout files ----
-
- // End of output